package gui;
import javax.swing.AbstractButton;
import javax.swing.DefaultListModel;
import javax.swing.JPanel;
import javax.swing.JButton;
import javax.swing.JScrollPane;
import javax.swing.ScrollPaneConstants;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.JSeparator;

import Entity.*;
import controllers.ManagerUIP;
import controllers.OBLSettings;
import controllers.WelcomeUIP;
import messagesPacks.*;
import java.awt.*;
import javax.swing.*;
import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.util.Enumeration;

import javax.swing.JList;
import javax.swing.border.MatteBorder;
/**
 * @author Ariel Brucker
 * The UI CLASS FOR THE VIEW EMPLOYESS(GUI)
 */
public class ManagerViewEmployeesUI extends JPanel
{
	private static final long serialVersionUID = 1L;
	ManagerMainUI managerMainUI=null;
	private DefaultListModel<String> lstUser;
	JList listOfEmployees;
	private JLabel lblOblManager;
	public JButton btnLogout;
	public JButton btnExit;
	public JButton btnBack;
	private JScrollPane scrollPane;
	ManagerUIP muip=null; 
	private final JSeparator separator = new JSeparator();
	public UsersMSG usersMSG;
	public SimpleTable SubTable;
	public ManagerViewEmployeesUI(ManagerMainUI managerMainUI) 
	{
		super();
		this.managerMainUI=managerMainUI;
		this.muip=new ManagerUIP();
		initialize();
	}
    private void initialize()
    {
    	this.setSize(OBLSettings.pane2Size[0],OBLSettings.pane2Size[1]);
    	usersMSG=muip.ViewAllEmployees();
    	setLayout(null);
    	separator.setBounds(0, 57, 855, 30);
		add(separator);
		lblOblManager = new JLabel("OBL Manager-View Employees");
		lblOblManager.setFont(new Font("Tahoma", Font.BOLD, 20));
		lblOblManager.setBounds(173, 0, 348, 58);
		add(lblOblManager);
		btnExit = new JButton("Exit");
		btnExit.setFont(new Font("Tahoma", Font.BOLD, 15));
		btnExit.setBounds(707, 11, 83, 41);
		add(btnExit);
		btnBack = new JButton("Back");
		btnBack.setFont(new Font("Tahoma", Font.BOLD, 15));
		btnBack.setBounds(10, 11, 83, 41);
		add(btnBack);
		btnLogout = new JButton("Logout");
		btnLogout.setFont(new Font("Tahoma", Font.BOLD, 15));
		btnLogout.setBounds(614, 11, 83, 41);
		add(btnLogout);
		Object ColNames[] = { "ID", "Password", "Permmision","Status" ,"FirstName","LastName","Address","E-mail","PhoneNum" };
		SubTable = new SimpleTable(null, ColNames, 10, 328, 780, 198);
	    add(SubTable.tblScrollPane,BorderLayout.CENTER);
    
		for (User var : usersMSG.getUsers().values())
        {
			SubTable.model.addRow(new Object[] {var.getID(),var.getPassword(),var.getPermmision(),var.getStatus(),var.getFname(),var.getLname()
					,var.getAddress(),var.getEmail(),var.getPhone()});
        }
    	
    
    	// ===========================================================================================
//		 Action Listeners
//     
		//back button (back to librarian main panel)
		btnBack.addActionListener(new ActionListener() 
		{
			public void actionPerformed(ActionEvent e) 
			{
				WelcomeUI.wui.switchPanel("OBL  - Manager", managerMainUI, OBLSettings.pane2Size[0], OBLSettings.pane2Size[1]);
			
			}
		});
		
		
	}
	public void paintComponent(Graphics g) 
	{
		g.drawImage((OBLSettings.IMG_DEFAULT_BACKGROUND).getImage(), 0, 0, OBLSettings.pane2Size[0], OBLSettings.pane2Size[1],null);
		
	}
   
}
